//
//  UIView+Extension.swift
//  ZHLEEBlog_swift_pro
//
//  Created by ZHLEEBlander on 15/10/11.
//  Copyright © 2015年 ZHLEEBlander. All rights reserved.
//

import Foundation
import UIKit
// MARK: - UIView分类 快速获取uiview控件的图形和位置属性值
extension UIView{
    
    var width: CGFloat {
    
        get{
        
            return self.frame.width
        }
        set{
        
            var frame = self.frame
            frame.size.width = newValue
            self.frame = frame
        }
    }
    
    var height: CGFloat{
    
        get{
        
            return self.frame.height
        }
        set{
        
            var frame = self.frame
            frame.size.height = newValue
            self.frame = frame
        }
    }
    var x: CGFloat{
        
        get{
            
            return self.frame.origin.x
        }
        set{
            
            var frame = self.frame
            frame.origin.x = newValue
            self.frame = frame
        }
    }
    var y: CGFloat{
        
        get{
            
            return self.frame.origin.y
        }
        set{
            
            var frame = self.frame
            frame.origin.y = newValue
            self.frame = frame
        }
    }
    
    var centerX: CGFloat{
        
        get{
            
            return self.center.x
        }
        set{
            
            var center = self.center
            center.x = newValue
            self.center = center
        }
    }
    var centerY: CGFloat{
        
        get{
            
            return self.center.y
        }
        set{
            
            var center = self.center
            center.y = newValue
            self.center = center
        }
    }
    
    var size: CGSize{
        
        get{
            
            return self.frame.size
        }
        set{
            
            var frame = self.frame
            frame.size = newValue
            self.frame = frame
        }
    }
}

